<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div id="outer">
		<input type="text" id="first">+<input type="text" id="second">=<div id="sum">?</div><input type="button" value="求和">
	</div>
    <script>
        window.onload = function() {
			var oInput = document.getElementsByTagName("input");
			for(var i=0;i<2;i++) {
				oInput[i].onkeyup = function() {
					this.value = this.value.replace(/[^\d|","]/,"");
				}
				oInput[2].onclick = function() {
					var f = document.getElementById("first").value;
					var s = document.getElementById("second").value;
					var oSum = document.getElementById("sum");
					var sum = 0
					console.log(oSum);
					sum += parseInt(f) + parseInt(s);
					oSum.innerHTML = sum;
				}
			}				
		}		
    </script>
</body>
</html>